package com.example.lowbird.lowbird.view;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.lowbird.lowbird.R;
import com.example.lowbird.lowbird.activity.MylistActivity;
import com.example.lowbird.lowbird.app.Myapp;

/**
 * Created by Administrator on 2016/11/7.
 */

public class Mflist extends LinearLayout {
    private ImageView iv_mylist;
    private TextView tv_mflist;
    private String text;
    private Drawable image;
    private View view;
    private Context context;

    private Intent intent;

    public Mflist(Context context) {
        this(context, null);
    }

    public Mflist(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public Mflist(final Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Mflist);
        text = typedArray.getString(R.styleable.Mflist_textt);
        image = typedArray.getDrawable(R.styleable.Mflist_imagei);

        view = View.inflate(context, R.layout.mf_listout, this);


        view.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

                if (intent != null) {
                    context.startActivity(intent);

                }

            }
        });
        initview(view);
        iv_mylist.setImageDrawable(image);

        tv_mflist.setText(text);

    }

    private void initview(View view) {
        iv_mylist = ((ImageView) view.findViewById(R.id.iv_mflist));
        tv_mflist = ((TextView) view.findViewById(R.id.tv_mflist));

    }


    public Intent getIntent() {
        return intent;
    }

    public void setIntent(Intent intent) {
        this.intent = intent;
    }
}
